package org.misalen.web.database.model.mysql.sys;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.misalen.annotations.ModelComment;
import org.misalen.web.database.model.mysql.BaseSqlModel;

/**
 * 角色/组织机构
 * 
 * @author guochao
 *
 */
@Entity
@Table(name = "SysRole")
@DynamicInsert(true)
@DynamicUpdate(true)
public class SysRole extends BaseSqlModel {

	@ModelComment("名称")
	@Column(name = "roleName", length = 50, nullable = false)
	private String roleName;

	@ModelComment("描述")
	@Column(name = "roleDesc", length = 50, nullable = false)
	private String roleDesc;

	@ModelComment("编码")
	@Column(name = "code", length = 50, nullable = false, unique = true)
	private String code;

	@ModelComment("排序字段")
	@Column(name = "seq", length = 10, nullable = false)
	private Integer seq;

	@ModelComment("状态")
	@Column(name = "usingState")
	private String usingState;

	@ModelComment("用户角色关系")
	@OneToMany(targetEntity = SysAdminRole.class, cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
	@JoinColumn(name = "roleId", updatable = false)
	private Set<SysAdminRole> sysAdminRoles;

	@ModelComment("角色资源关系")
	@OneToMany(targetEntity = SysRoleResources.class, cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
	@JoinColumn(name = "roleId", updatable = false)
	private Set<SysRoleResources> sysRoleResources;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRoleDesc() {
		return roleDesc;
	}

	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	public String getUsingState() {
		return usingState;
	}

	public void setUsingState(String usingState) {
		this.usingState = usingState;
	}

	public Set<SysAdminRole> getSysAdminRoles() {
		return sysAdminRoles;
	}

	public void setSysAdminRoles(Set<SysAdminRole> sysAdminRoles) {
		this.sysAdminRoles = sysAdminRoles;
	}

	public Set<SysRoleResources> getSysRoleResources() {
		return sysRoleResources;
	}

	public void setSysRoleResources(Set<SysRoleResources> sysRoleResources) {
		this.sysRoleResources = sysRoleResources;
	}

}
